package com.xh.chat.netty.bootstrap;

import com.xh.chat.netty.event.EventHandlerFactory;
import org.springframework.beans.BeansException;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class NettyBootStrap implements CommandLineRunner, ApplicationContextAware {

    private ApplicationContext applicationContext;

    @Override
    public void run(String... strings) {
        // 加载事件工厂
        EventHandlerFactory.init(applicationContext);
        // 启动Netty服务
        WSServer.INSTANCE.start();
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

}
